//
//  XQReadingViewController.m
//  Reading
//
//  Created by 军哥 on 15-1-27.
//  Copyright (c) 2015年 军哥. All rights reserved.
//

#import "XQReadingViewController.h"
#import "XQReadCell.h"
#import "TitleCell.h"
#import "WriterCell.h"
@interface XQReadingViewController ()<UITableViewDataSource,UITableViewDelegate>

@end

@implementation XQReadingViewController
- (void)dealloc
{
    [_tabel release];
    [_arr release];
    [super dealloc];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor redColor];
    self.title = @"文章";
    
    
    //文章tabelView
   _tabel = [[UITableView alloc]initWithFrame:self.view.bounds style:UITableViewStylePlain];
    _tabel.backgroundColor = [UIColor orangeColor];
    _tabel.delegate = self;
    _tabel.dataSource = self;
    _tabel.tableFooterView = [[[UIView alloc]init]autorelease];
    [self.view addSubview:_tabel];
    [_tabel release];
    
    /*******************假设文章内容*******************/
    self.arr =[NSMutableArray arrayWithObjects:@"走好,姑凉",@"ddddddddddddddsaaaaaaaaaaaaddddddddddddddddddddddddddddddddddddddddnkasdjkjd阿娇是肯定就困了就立刻就快到了;斯卡拉贷款多少;阿里看到了;刷卡的;老是卡佛饿哦发扣扣了;手机福利绝对是;困了就疯狂的减肥快乐      大家是否考虑将第三方;离开家都是可怜见佛浦发的快速减肥快恢复分类的开始了房价肯定了佛牌饿哦就放暑假的法律;空间都死了;附近的顺口溜;积分大师傅的说法;的路上就发生的;浪费第三方;代理商福建省的;                飞水电费;老师的减肥;劳动时间富士康;点击发送科技覅还好丢撒旦撒个不大哈师大 肯德基撒客户的骄傲和圣诞节噶解释道嘎都干撒DSA的哭声 阿卡家还是丢我会员和登记卡还是发顺丰;拉客户发啊说的是卡号的厉害撒旦啊;LSD啊;路上看到哈林是的哈里解放公司经过发空间更大数据库等哈就的哟文化大空间的考虑好打发时间看好的就撒旦会卡机的哈的撒加快递哈的撒娇的户外就暗示的感觉按空格打卡时间和大家看到哈市",@"走好,姑凉的作者", nil];
    
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.arr.count;
}
//cell 设置
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0){
    static NSString *str = @"jun";
    TitleCell *cell = [tableView dequeueReusableCellWithIdentifier:str];
    if (cell == nil) {
        cell = [[[TitleCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:str]autorelease];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
        /***************假设文字*************/
    cell.titleLabel.text = [self.arr objectAtIndex:indexPath.row];
        cell.zuoZhelabel.text = @"by:这么远那么近";
        cell.timeLabel.text = @"11 min read";
    return cell;
  }else if (indexPath.row == 1){
      static NSString *str = @"jun";
      XQReadCell *cell = [tableView dequeueReusableCellWithIdentifier:str];
      if (cell == nil) {
          cell = [[[XQReadCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:str]autorelease];
          cell.selectionStyle = UITableViewCellSelectionStyleNone;
      }
      cell.mylabel.text = [self.arr objectAtIndex:indexPath.row];
      return cell;
  }else {
      static NSString *str = @"jun";
      UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:str];
      if (cell == nil) {
          cell = [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:str]autorelease];
          cell.selectionStyle = UITableViewCellSelectionStyleNone;
      }
      cell.textLabel.text = [self.arr objectAtIndex:indexPath.row];
      return cell;
      
  }
  }
    



//文章自适应高度
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{//获取要显示的文本内容
    if(indexPath.row == 1){
    NSString *str = [self.arr objectAtIndex:indexPath.row];
    NSDictionary *dic = @{NSFontAttributeName:[UIFont systemFontOfSize:17]};
    CGRect rect = [str boundingRectWithSize:CGSizeMake(tableView.frame.size.width, 1000) options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    return rect.size.height;
    }else if (indexPath.row == 0){
        return 100;
    }else {
        return 50;
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
